<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>口令提取</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        .goods-item {
            width: 100%;
            padding: 0 2.6vw;
        }
        .img-box {
            width: 100%;
            border-radius: 4.6vw;
            overflow: hidden;
            position: relative;
        }
        .img-box img {
            width: 100%;
            display: block;
        }
        .img-box .coupon {
            position: absolute;
            bottom: 0;
            left: 0;
            background: #F91015;
            color: #FCF3BF;
            padding: 1.5vw 4vw;
            border-radius: 0 4.6vw 0 0;
            font-size: 3.6vw;
        }
        .img-box .coupon span {
            font-size: 6.6vw;
        }
        .goods-name {
            margin-top: 3vw;
            margin-bottom: 5vw;
        }
        .end-price {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .end-price .coupon-price {
            font-size: 3.6vw;
            color: #F91015;
        }
        .end-price .coupon-price span {
            font-size: 6.6vw;
        }
        .end-price .coupon {
            background: #F91015;
            padding: 1.5vw 3vw;
            color: #FFF7C9;
            border-radius: 1.6vw;
        }
        .end-price a {
            color: #FFF7C9;
        }
        .end-price .coupon span {
            margin-left: 2vw;
            border-left: 2px dotted #FFF7C9;
            padding-left: 2vw;
        }
        .old-price {
            font-size: 3.6vw;
            color: #717076;
            margin-top: 2vw;
        }
        .old {
            margin-right: 3vw;
            text-decoration: line-through;
        }
        .copy-box {
            margin: 7vw auto;
            width: 80vw;
            background: #FFFAF9;
            border-radius: 3.2vw;
            border: 2px solid #FDC1C5;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            padding: 2vw 0;
        }
        .copy-box p {
            color: #221D2C;
            font-size: 4vw;
        }
        .copy-box a {
            margin-top: 4vw;
            width: 24vw;
            line-height: 8vw;
            background: #F70114;
            color: #fff;
            border-radius: 50px;
            display: block;
            font-size: 4vw;
            text-align: center;
        }
        .toast {
            width: 24vw;
            line-height: 10vw;
            background: rgba(0, 0, 0, 0.7);
            color: #fff;
            font-size: 4vw;
            text-align: center;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-left: -12vw;
            margin-top: -5vw;
            border-radius: 1.6vw;
            opacity: 0;
            transition: 0.5s;
        }
        .toast.show {
            opacity: 1;
        }
    </style>
</head>

<body>
<div class="goods-item">
    <div class="img-box">
        <img src="" alt="" id="pic">
        <div class="coupon">券后¥<span id="endPrice1"></span>
        </div>
    </div>
    <p class="goods-name" id="title"></p>
    <div class="end-price">
        <div class="coupon-price">券后¥<span id="endPrice2"></span>
        </div>
        <div class="coupon">¥
            <a id="couponMoney"></a><span>券</span>
        </div>
    </div>
    <div class="old-price">
        原价<span class="old">¥<span id="price"></span></span>
        <span class="sale">销量<span id="sale"></span></span>
    </div>
    <div class="copy-box">
        <p>点击按钮，打开👉陶寳┡ē👈即可</p>
        <p id="tkl"></p>
        <a onclick="copy()">点击</a>
    </div>
</div>

<div class="toast" id="toast">复制成功</div>

<script>
	let inviteCode = getParams('inviteCode');
	if (inviteCode) {
		window.location.href = 'https://www.baidu.com?inviteCode=' + inviteCode
	}
	function copy() {
		let input = document.createElement("input"); // 直接构建input
		input.value = getParams('tkl'); // 设置内容
		document.body.appendChild(input); // 添加临时实例
		input.select(); // 选择实例内容
		document.execCommand("Copy"); // 执行复制
		document.body.removeChild(input); // 删除临时实例

		document.getElementById("toast").classList.add("show");
		setTimeout(() => {
			document.getElementById("toast").classList.remove("show");
		}, 2000)
	}

	function getParams(paras) {
		let url = decodeURI(location.href);
		let paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
		let returnValue;
		for (let i = 0; i < paraString.length; i++) {
			let tempParas = paraString[i].split('=')[0];
			let parasValue = paraString[i].split('=')[1];
			if (tempParas === paras)
				returnValue = parasValue;
		}
		if (typeof(returnValue) == "undefined") {
			return "";
		} else {
			return returnValue;
		}
	}

	window.onload = function() {
		document.getElementById('endPrice1').innerHTML = getParams('endPrice');
		document.getElementById('endPrice2').innerHTML = getParams('endPrice');
		document.getElementById('title').innerHTML = getParams('title');
		document.getElementById('couponMoney').innerHTML = getParams('couponMoney');
		document.getElementById('price').innerHTML = getParams('price');
		document.getElementById('sale').innerHTML = getParams('sale');
		document.getElementById('tkl').innerHTML = getParams('tkl');
		document.getElementById('pic').src = getParams('pic');
	}
</script>
</body>

</html>
